import {ref} from 'vue'
import TextProblem from '@/types/testProblem'
import request from '@/base/request'
import { ElMessage } from 'element-plus'
import router from '@/router'

export default function(){

    const examProblem=ref<TextProblem>(

    )


    async function getExamProblemList(examId:number) {
        const response=(await request.get(`/problem/exam/getExamProblemList/${examId}`)).data
        if(response.code===200 || response.code===510){
            examProblem.value=response.data;
            if(response.code===510)ElMessage.info(response.msg)
        }
        else{
            ElMessage.error(`获取题目列表失败,${response.msg}`)
            router.push('/home')
        }
    }




    return {examProblem,getExamProblemList}
}